package rexsee.ebook;

import rexsee.core.browser.Browser;
import rexsee.core.style.RexseeDrawable;
import rexsee.core.widget.DivDialog;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.view.KeyEvent;

public class PageFlipDialog extends DivDialog {

	public PageView pageView;

	public PageFlipDialog(Browser browser, String dialogId, String style) {

		super(browser, dialogId, style);

		Drawable pageBack = RexseeDrawable.getDrawable(browser, styleSheet.background_color);
		Drawable background = RexseeDrawable.getDrawable(browser, styleSheet.label_background_color);

		pageView = new PageView(browser, dialogId, style, null, null, pageBack, background);
		this.addChild(pageView);

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			if (mBrowser.menu.isOptionsMenuOpen) {
				((Activity) mContext).closeOptionsMenu();
				return true;
			} else {
				if (styleSheet.window_cancelable.equalsIgnoreCase("true")) dismiss();
			}
		} else if (keyCode == KeyEvent.KEYCODE_MENU) {
			((Activity) mContext).openOptionsMenu();
		} else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
			return true;
		} else if (keyCode == KeyEvent.KEYCODE_FOCUS) {
		} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
		} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
		} else {
		}
		return false;
	}

}
